/*请定义一个交通工具(Vehicle)的类，其中有:
属性：速度(speed)，体积(size)等等  方法：移动(move())，
设置速度(setSpeed(int speed))，加速speedUp(),
减速speedDown()等等.最后在测试类Vehicle中的main()
中实例化一个交通工具对象，并通过构造方法给它初始化
speed,size的值，并且通过打印出来。另外，调用加速，
减速的方法对速度进行改变。
 */
package day20171019;

public class Vehicle {
    //属性
    double speed;
    double size;

    public Vehicle(double speed, double size) {//有参构造
        this.speed = speed;
        this.size = size;
        System.out.println("speed is " + speed);
        System.out.println("size is " + size);
    }

    //行为
    public void move() {
        System.out.println("I am moving.");
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public void speedUp() {
        speed = speed + 50;
        System.out.println("The speed is turn up to:" + speed);
    }

    public void speedDown() {
        speed = speed - 20;
        System.out.println("The speed is turn up to:" + speed);
    }

    public static void main(String[] args) {
        Vehicle v = new Vehicle(31, 56);
        v.move();
        v.setSpeed(78);
        v.speedUp();
        v.speedDown();
    }
}
